import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: dell
 * Date: 2024-01-11
 * Time: 17:35
 */
class MyQueue {
    Stack<Integer> stack1;
    Stack<Integer> stack2;
    public MyQueue() {
        stack1=new Stack<>();
        stack2=new Stack<>();
    }

    public void push(int x) {
        stack1.push(x);
    }

    public int pop() {
        if (stack2.empty()) {
            int tnp = stack1.size();
            for (int i = 0; i < tnp; i++) {
                int val = stack1.pop();
                stack2.push(val);
            }
        }
        return stack2.pop();
    }

    public int peek() {
        if (stack2.empty()) {
            int tnp = stack1.size();
            for (int i = 0; i < tnp; i++) {
                int val = stack1.pop();
                stack2.push(val);
            }
        }
        return stack2.peek();
    }

    public boolean empty() {
        return stack2.empty()&&stack1.empty();
    }
}

/**
 * Your MyQueue object will be instantiated and called as such:
 * MyQueue obj = new MyQueue();
 * obj.push(x);
 * int param_2 = obj.pop();
 * int param_3 = obj.peek();
 * boolean param_4 = obj.empty();
 */